package com.ibiaoke.goods.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.common.consts.CommonConsts;
import com.ibiaoke.goods.entity.GoodsClass;
import com.ibiaoke.goods.entity.GoodsClassExample;
import com.ibiaoke.goods.entity.XcxGoodsClass;
import com.ibiaoke.goods.entity.XcxGoodsClassExample;
import com.ibiaoke.goods.mapper.GoodsClassMapper;
import com.ibiaoke.goods.mapper.XcxGoodsClassMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class XcxGoodsClassDao extends BaseDao<XcxGoodsClass,XcxGoodsClassExample,Integer,XcxGoodsClassMapper> {

    @Autowired
    private XcxGoodsClassMapper xcxGoodsClassMapper;

    @Override
    public XcxGoodsClassMapper getMapper() {
        return xcxGoodsClassMapper;
    }


    public List<XcxGoodsClass> xcxListGoodsClass(){
        XcxGoodsClassExample example = new XcxGoodsClassExample();
        example.createCriteria().andLevelEqualTo(CommonConsts.YES).andDelStatusEqualTo((byte) CommonConsts.NO);
        example.setOrderByClause("gc_sort");
        return  xcxGoodsClassMapper.selectByExample(example);
    }

    public int deleteByGoodsClassId(Integer xcxGoodsClassId) {
        XcxGoodsClassExample example = new XcxGoodsClassExample();
        example.createCriteria().andGcIdEqualTo(xcxGoodsClassId);
        XcxGoodsClass xcxGoodsClass = new XcxGoodsClass();
        xcxGoodsClass.setDelStatus((byte) CommonConsts.YES);
        return xcxGoodsClassMapper.updateByExampleSelective(xcxGoodsClass, example);
    }
}
